#include "SSFinancialCompany.h"

#include <fstream>

CSSFinancialCompanyInfo::CSSFinancialCompanyInfo(void) {}

CSSFinancialCompanyInfo::~CSSFinancialCompanyInfo(void) { Clear(); }

CSSFinancialCompanyInfo& CSSFinancialCompanyInfo::instance() {
  static CSSFinancialCompanyInfo s_fci;
  return s_fci;
}

void CSSFinancialCompanyInfo::Clear() {
  std::lock_guard<std::mutex> l(m_mutex);
  m_map.clear();
}

int CSSFinancialCompanyInfo::Size() { return m_map.size(); }

void CSSFinancialCompanyInfo::Lock() { m_mutex.lock(); }

void CSSFinancialCompanyInfo::Unlock() { m_mutex.unlock(); }

void CSSFinancialCompanyInfo::Add(const char* companyId,
                                  const QBFINANCIALCOMPANYINFO& info) {
  if (companyId == nullptr || companyId[0] == '\0') return;
  m_map[companyId] = info;
  return;
}

void CSSFinancialCompanyInfo::Remove(const char* companyId) {
  if (companyId == nullptr || companyId[0] == '\0') return;
  CompanyMap::iterator it = m_map.find(companyId);
  if (it != m_map.end()) {
    m_map.erase(it);
  }
}

void CSSFinancialCompanyInfo::DumpStatus(int mode) const {}
